<?php    
    if (php_sapi_name() != 'cli' ) {
        die('Must be run from the command line.' );
    }
     
    require_once('db.php'); //Require/include the file with the database connection information
    require_once('functions.php'); //Require/include the functions file
     
    //Connect to DB and connect to the database using db.php
    $db = new my_db;
     
    $db->query("SELECT * FROM trackedfiles");
     
    // keep getting the next row until there are no more to get
    while ($db->next_record()) {
        $filepath = $db->f('filepath');
        $filename = $db->f('filename');
        $id = $db->f('id');
        $latestrev = $db->f('latestrev');
        $status = updatefilestatus ($latestrev, "$filepath$filename");
        if ($status !== 'nochange' AND $status !== 'badfile' AND $status !== 'isdir' AND $status !== 'cannotread') {
            $status = updatefile($id, $status, '', $filepath, $filename);
        }
    }
     
?>